package com.atgm.mall.gmmailproduct.controller;

import com.atgm.common.utils.R;
import com.atgm.mall.gmmailproduct.entity.GameTypeEntity;
import com.atgm.mall.gmmailproduct.service.GameTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 游戏类型
 */
@RestController
@RequestMapping("gmmallproduct/gametype")
public class GameTypeController {

    @Autowired
    private GameTypeService gameTypeService;

    @GetMapping("/list")
    public R getGameTypeList() {
        List<GameTypeEntity> list = gameTypeService.queryList();
        return R.ok().setData(list);
    }

    @GetMapping("/info/{id}")
    public R getGameTypeById(@PathVariable("id") Long id) {
        GameTypeEntity gameTypeEntity = gameTypeService.getById(id);
        return R.ok().setData(gameTypeEntity);
    }

    @PostMapping("add")
    public R addGameType(@RequestBody GameTypeEntity gameTypeEntity) {
        gameTypeService.insertGameType(gameTypeEntity);
        return R.ok();
    }

    @DeleteMapping("delete/{id}")
    public R deleteGameType(@PathVariable("id") Long id) {
        gameTypeService.removeGameTypeById(id);
        return R.ok();
    }

    @PutMapping("update")
    public R updateGameType(@RequestBody GameTypeEntity gameTypeEntity) {
        gameTypeService.updateGameType(gameTypeEntity);
        return R.ok();
    }
}
